package com.advertise.model;

import java.util.HashSet;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;




@Entity
@Table(name = "user")

public class User {
	private int userId;
	private String loginName;
	
	private String userName;
	private String eMail;
	
	private String password;
	private String userType;
	private UserState state;
	
	private boolean canbeDelete;
	

	@Column(name="state")
	@Enumerated(value = EnumType.ORDINAL)
	public UserState getState() {
		return state;
	}
	
	
	public void setState(UserState state) {
		this.state = state;
	}

	private Set<Role> roles	=	new HashSet<Role>(0);
	
	@ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
	@JoinTable(name="roleUsers",joinColumns={@JoinColumn(name="userId")},
			inverseJoinColumns={@JoinColumn(name="roleId")})
	public Set<Role> getRoles() {
		return roles;
	}




	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}




	public User(){
		
	}
	
	
	


	@Id
	@Column(name="userId",unique = true, nullable = false)
	public int getUserId() {
		return userId;
	}




	public void setUserId(int userId) {
		this.userId = userId;
	}




	@Column(name="loginName",nullable=false)
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	

	@Column(name="password" ,nullable=false)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	@Column(name="userType")
	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}
	
	@Column(name="canbeDelete")
	public boolean isCanbeDelete() {
		return canbeDelete;
	}

	public void setCanbeDelete(boolean canbeDelete) {
		this.canbeDelete = canbeDelete;
	}

	@Column(name="userName")
	public String getUserName() {
		return userName;
	}


	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name="eMail")
	public String geteMail() {
		return eMail;
	}


	public void seteMail(String eMail) {
		this.eMail = eMail;
	}
	
	
	
	
}
